package mGraph.algorithm.LinkPrediction.entity;

import java.math.BigDecimal;

import mGraph.MTEdge;

/**
 * 
 * @author Giulio Rossetti
 *
 */
public class PredictedEdge  extends MTEdge implements Comparable<PredictedEdge>{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1432461534276549997L;
	private int d;
	private Double p;
	
	
	
	/**
	 * 
	 * @param x
	 * @param y
	 * @param d
	 * @param p
	 */
	public PredictedEdge(int x, int y, int d, double p){
		super(x,y);
		this.d=d;
		this.p=p;
	}
	
	
	/**
	 * 
	 * @param x
	 * @param y
	 */
	public PredictedEdge(int x, int y) {
		super(x,y);
	}
	
	
	/**
	 * 
	 * @param d
	 * @param score
	 */
	public void addPredictedValue(int d,double score){
		this.d = d;
		this.p = score;
	}
	

	/**
	 * 
	 * @param value
	 */
	public void setPredictedValue(double value){
		this.p=value;
	}
	
	
	/**
	 * 
	 * @return
	 */
	public double getPredictedValue() {
		return this.p;
	}
	
	
	public int getDimension() {
		return this.d;
	}
		
	
	/**
	 * 
	 */
	public String toString() {
		
		if(this.p.isInfinite()) this.p = Double.MAX_VALUE;
			
		String res = "e "+this.x+" "+this.y+" "+this.d+" "+(new BigDecimal(Double.toString(this.p))).toPlainString();
				
		return res;
		
		}
	
	
	/**
	 * 
	 */
	public boolean equals(Object o){
		PredictedEdge e = (PredictedEdge) o;
		
		
		if(e.x==this.x && e.y==this.y && e.d==this.d){
			return true;
		}
		else return false;
	}
	

	/**
	 * 
	 */
	public int compareTo(PredictedEdge e) {
		final int BEFORE = -1;
		final int EQUAL = 0;
		final int AFTER = 1;
		    
		if(this.p == e.p) return EQUAL;
		else if(this.p < e.p) return AFTER;
		else return BEFORE;
	}





}
